package cn.schoolwow.workflow.module.initial.handler;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.listener.TryCatchFinallyHandler;

public class WorkFlowTryCatchFinallyHandler implements TryCatchFinallyHandler {
    @Override
    public void handleTryStart(FlowContext flowContext) throws Exception {
        DAO workFlowDAO = flowContext.checkInstanceData(DAO.class);
        workFlowDAO.startRecord();
    }

    @Override
    public void handleTryEnd(FlowContext flowContext) throws Exception {

    }

    @Override
    public void handleException(FlowContext flowContext, Exception e) {
        DAO workFlowDAO = flowContext.checkInstanceData(DAO.class);
        System.out.println(workFlowDAO.stopRecord());
    }

    @Override
    public void handleFinally(FlowContext flowContext) {
        DAO workFlowDAO = flowContext.checkInstanceData(DAO.class);
        workFlowDAO.stopRecord();
    }

    @Override
    public String name() {
        return "工作流全局异常处理处理器";
    }
}
